Skip to content

bool -> Primitive casts - #8621

Merged
myrrc merged 1 commit into
developfrom
myrrc/bool-to-primitive-cast
Jun 29, 2026
Merged

bool -> Primitive casts#8621
myrrc merged 1 commit into
developfrom
myrrc/bool-to-primitive-cast

Conversation

@myrrc

@myrrc myrrc commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Support of bool -> Primitive casts.
This is a subtask for pushing expressions of form
"WHERE prefix(...) > 0" to Duckdb.

@myrrc
myrrc requested a review from a team June 29, 2026 13:12
@myrrc myrrc added the changelog/feature A new feature label Jun 29, 2026
@myrrc
myrrc requested a review from 0ax1 June 29, 2026 13:12
@myrrc
myrrc enabled auto-merge (squash) June 29, 2026 13:12
@myrrc myrrc mentioned this pull request Jun 29, 2026
@0ax1
0ax1 disabled auto-merge June 29, 2026 13:19

@0ax1 0ax1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, one nit.

Comment thread vortex-array/src/arrays/bool/compute/cast.rs Outdated
Signed-off-by: Mikhail Kot <mikhail@spiraldb.com>
@myrrc
myrrc force-pushed the myrrc/bool-to-primitive-cast branch from 806c947 to 39ce91b Compare June 29, 2026 13:21
@myrrc
myrrc enabled auto-merge (squash) June 29, 2026 13:22
@codspeed-hq

codspeed-hq Bot commented Jun 29, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 20.87%

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

⚡ 4 improved benchmarks
❌ 1 regressed benchmark
✅ 1590 untouched benchmarks
⏩ 4 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation slice_empty_vortex 339.4 ns 397.8 ns -14.66%
Simulation chunked_bool_canonical_into[(1000, 10)] 26.9 µs 15.9 µs +69.52%
Simulation bitwise_not_vortex_buffer_mut[128] 273.6 ns 215.3 ns +27.1%
Simulation bitwise_not_vortex_buffer_mut[1024] 333.9 ns 275.6 ns +21.17%
Simulation bitwise_not_vortex_buffer_mut[2048] 427.8 ns 369.4 ns +15.79%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing myrrc/bool-to-primitive-cast (39ce91b) with develop (00c39e8)

Open in CodSpeed

Footnotes

  1. 4 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@myrrc
myrrc merged commit 173f664 into develop Jun 29, 2026
77 of 79 checks passed
@myrrc
myrrc deleted the myrrc/bool-to-primitive-cast branch June 29, 2026 13:35
Ok(Some(match_each_native_ptype!(*new_ptype, |T| {
let (one, zero) = (<T as One>::one(), <T as Zero>::zero());
let mut buffer = BufferMut::<T>::with_capacity(len);
buffer.extend(bits.iter().map(|v| if v { one } else { zero }));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Buffer::from_trusted_len_iter

@robert3005

Copy link
Copy Markdown
Contributor

I think these need to be separate

haohuaijin added a commit to openobserve/vortex that referenced this pull request Jul 29, 2026
…data#8621

The 0.75.0 port implemented bool -> primitive in `CastKernel for Bool`
because the 0.75 baseline only handled bool -> bool. Upstream landed the
same thing two weeks later in vortex-data#8621 (173f664), so the implementation
was already dropped in favour of upstream's during the cherry-pick.

Remove the two tests the port brought along with it; `cast_bool_to_primitive`
from vortex-data#8621 now covers this path.

Note the coverage is not identical: vortex-data#8621's test sweeps 7 ptypes but only
asserts `out.len() == 3` — it checks neither the converted values nor the
nullable case, both of which the removed tests did assert.

The scalar-level bool -> primitive/utf8 in `BoolScalar::cast` is NOT
covered by vortex-data#8621 and stays.

Signed-off-by: Huaijin <haohuaijin@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/feature A new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants